package com.yangj.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

import org.apache.commons.dbutils.ResultSetHandler;

import com.yangj.model.User;

public class UserDao extends BaseDao {
  public List<User> getAll() {
        try {
          List<User> list = new LinkedList<>();
            String sql = "select pet_name, name, phone, icon, attention, fans, recentvisits, footmark from userinfo";
            return queryRunner.query(sql,new ResultSetHandler<List<User>>() {
        @Override
        public List<User> handle(ResultSet rs) throws SQLException {
          while(rs.next()) {
            list.add(new User(rs.getString("pet_name"),
                rs.getNString("name"),
                rs.getString("phone"),
                rs.getString("icon"),
                rs.getInt("attention"),
                rs.getInt("fans"),
                rs.getInt("recentvisits"),
                rs.getInt("footmark")));
            
          }
          return list;
        }    
            });
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}